package com.ailanyin.modules.job.task;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ailanyin.modules.job.mapper.SysJobLogMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 删除任务日志
 *
 * @author ailanyin
 * @version 1.0
 * @since 2022/11/25 0025 下午 14:01
 */
@Component("deleteJobLogTask")
public class DeleteJobLogTask {

    @Resource
    private SysJobLogMapper sysJobLogMapper;

    public void delete(Integer day) {
        DateTime dateTime = DateUtil.offsetDay(new DateTime(), -day);
        sysJobLogMapper.cleanJobLogByBeforeTime(dateTime.toString(DatePattern.NORM_DATETIME_PATTERN));
    }
}
